<h2>Task details</h2>
<?php
    $this->headTitle('View task details');
    $this->headScript()->appendFile('/js/BizSense/Crud.js'); 
    $taskDetails = $this->task;
    $taskId = $taskDetails['task_id'];
    $acl = $this->acl;
?>

<div class="clearing"> </div>

<?php if  ($acl->isAllowed($this->currentUser, 'access task pages')): ?>
<a href="<?php echo $this->url(array(
        'module'        => 'activity',
        'controller'    => 'task',
        'action'        => 'index'
        )); ?>">Tasks</a>
&nbsp;|&nbsp;
<?php endif; ?>

<?php if  ($acl->isAllowed($this->currentUser, 'delete all tasks')):
    $deleteUrl = $this->url(
                    array(
                        'module' => 'activity',
                        'controller' => 'task',
                        'action' => 'delete',
                    )
                );
                echo $this->deleteButton($deleteUrl); 
 endif; ?>
&nbsp;|&nbsp;
<?php if  ($acl->isAllowed($this->currentUser, 'edit all tasks')): ?>
<a href="<?php echo $this->url(array(
        'module'        => 'activity',
        'controller'    => 'task',
        'action'        => 'edit'
        )); ?>">Edit</a>
&nbsp;|&nbsp;
<?php endif; ?>

<?php if  ($acl->isAllowed($this->currentUser, 'access task pages')): ?>
<a href="<?php echo $this->url(array(
        'module'        => 'activity',
        'controller'    => 'task',
        'action'        => 'notes'
        )); ?>">Notes</a>
<?php endif; ?>

<table class="data_table">
   <tr>
        <td>Title</td>
        <td><?php echo $this->escape($taskDetails['name']); ?></td>
   </tr>
   
   <tr>
        <td>Status</td>
        <td><?php echo $this->escape($taskDetails['status']); ?></td>
   </tr>
   
   <tr>
        <td>Start date</td>
        <td><?php echo $this->escape(
                $this->timestampToHuman($taskDetails['start_date'])); ?></td>
   </tr>
   
   <tr>
        <td>Due date</td>
        <td><?php echo $this->escape(
                  $this->timestampToHuman($taskDetails['end_date'])); ?></td>
   </tr>
   
   <tr>
        <td>Created on</td>
        <td><?php echo $this->escape(
                    $this->timestampToHuman($taskDetails['created'])); ?></td>
   </tr>
   
   <tr>
        <td>Assigned to</td>
        <td><?php echo $this->escape($taskDetails['email']); ?></td>
   </tr>
   
   <tr>
        <td>Description</td>
        <td><?php echo $this->escape($taskDetails['description']); ?></td>
   </tr>
</table>


<?php if (count($this->notesPaginator)): ?>
    <table class="data_table">
        <tr>
            <th class="long">Notes
            </th>
            <th class="short">Created By
            </th>
            <th class="short">Created On
            </th>
        </tr>
    
<?php foreach ($this->notesPaginator as $item) {
    $itemRow = $item->toArray();
    $notesId = $this->escape($itemRow['task_notes_id']);
?>
    <tr>
        <td>
            <?php echo $this->escape($itemRow['notes']); ?>
        </td>
        <td>
            <?php echo $this->userLinkById($itemRow['created_by']); ?>
        </td>
        <td>
            <?php echo $this->escape($this->timestampToHuman($itemRow['created'])); ?>
        </td>

    </tr>        
<?php
    }
?>
    </table>
<?php endif; ?>
<a href="<?php echo $this->url(array(
        'module'        => 'activity',
        'controller'    => 'task',
        'action'        => 'notes',
        'task_id'       => $taskId,
        ), 'default', true); ?>">More Notes</a>

<a href="<?php echo $this->url(array(
        'module'        => 'activity',
        'controller'    => 'task',
        'action'        => 'createnotes',
        'task_id'       => $taskId,
        ), 'default', true); ?>">Create Note</a>



